package com.d.business.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.d.business.dao.DingProcessRecordsDao;
import com.d.business.domain.DingProcessRecordsDO;
import com.d.business.service.DingProcessRecordsService;


@Service
public class DingProcessRecordsServiceImpl implements DingProcessRecordsService {
    @Autowired
    private DingProcessRecordsDao dingProcessRecordsDao;

    @Override
    public DingProcessRecordsDO get(Integer id) {
        return dingProcessRecordsDao.get(id);
    }

    @Override
    public List<DingProcessRecordsDO> list(Map<String, Object> map) {
        return dingProcessRecordsDao.list(map);
    }

    @Override
    public int count(Map<String, Object> map) {
        return dingProcessRecordsDao.count(map);
    }

    @Override
    public int save(DingProcessRecordsDO dingProcessRecords) {
        return dingProcessRecordsDao.save(dingProcessRecords);
    }

    @Override
    public int update(DingProcessRecordsDO dingProcessRecords) {
        return dingProcessRecordsDao.update(dingProcessRecords);
    }

    @Override
    public int remove(Integer id) {
        return dingProcessRecordsDao.remove(id);
    }

    @Override
    public DingProcessRecordsDO getByBusindssNoAndTypeAndStatus(String businessNo, Integer businessType, String status) {
        Map<String, Object> m = new HashMap<>();
        m.put("businessNo", businessNo);
        m.put("businessType", businessType);
        m.put("instanceStatus", status);
        List<DingProcessRecordsDO> li = dingProcessRecordsDao.list(m);
        if (li == null)
            return null;
        return li.get(0);
    }

    @Override
    public DingProcessRecordsDO getByInstanceIdAndInstanceStatus(String instanceId, String instanceStatus) {
        Map<String, Object> m = new HashMap<>();
        m.put("instanceId", instanceId);
        m.put("instanceStatus", instanceStatus);
        List<DingProcessRecordsDO> li = dingProcessRecordsDao.list(m);
        if (li == null)
            return null;
        return li.get(0);
    }
}
